#coding:utf-8
"""
*   Coder    : Dzlua
*   Email    : 505544956@qq.com
*   Time     : 2017/09/06
"""
#--------------------#
from utilities import helper

#--------------------#
# use apis v2.0
from api2 import So, Dir, File, Select
from api2 import Register, GetUser, Users, Token

#--------------------#
class APIMgr:
    def __init__(self, flask, route_root=''):
        self._route_root = route_root
        self._api = helper.Api(flask)
    def add(self, api, route, endpoint):
        self._api.add_resource(api, self._route_root + route, endpoint=endpoint)
    def esay_add(self, api, name):
        self.add(api, name, name)
    def start(self):
        self.esay_add(So, 'so')
        self.esay_add(Dir, 'dir')
        self.esay_add(File, 'file')
        self.esay_add(Select, 'select')
        #
        self.esay_add(Register, 'register')
        self.esay_add(Users, 'users')
        self.esay_add(GetUser, 'get_user')
        self.esay_add(Token, 'token')
#--------------------#
